<template>
  <div class="bg">
    <div class="box">
      <div class="pic"><img src="../../assets/bg.png" alt="" /></div>
      <div class="left">
        <div class="left_pic">
          <img src="../../assets/pic.png" alt="" />
          <h3>客达天下</h3>
        </div>
        <el-form ref="form" :rules="rules" :model="formData">
          <el-form-item prop="userName">
            <el-input v-model="formData.userName" placeholder="请输入账号"
              ><i slot="prefix" class="el-input__icon el-icon-user"></i
            ></el-input>
          </el-form-item>
          <el-form-item prop="password">
            <el-input
              show-password
              v-model="formData.password"
              placeholder="请输入密码"
              ><i slot="prefix" class="el-input__icon el-icon-goods"></i
            ></el-input>
          </el-form-item>
          <el-form-item prop="code">
            <el-input v-model="formData.code" placeholder="请输入验证码"
              ><i slot="prefix" class="el-input__icon el-icon-search"></i
            ></el-input>
            <img class="code" src="../../assets/pig.jpg" alt="" />
          </el-form-item>
          <el-form-item>
            <el-button type="success" :loading="loading" @click="login"
              >登录</el-button
            >
          </el-form-item>
        </el-form>
        <p style="color: deeppink">
          仅用于IT培训教学使用，为保障您的个人信息安全，请勿向平台录入任何个人敏感信息（如手机号、身份证号等）！
        </p>
      </div>
    </div>
  </div>
</template>

<script>
import { Message } from "element-ui";
export default {
  name: "login",
  data() {
    return {
      loading: false,
      formData: {
        userName: process.env.NODE_ENV === "development" ? "demo" : "",
        password:
          process.env.NODE_ENV === "development" ? "888itcast.CN764%..." : "",
      },
      rules: {
        userName: [
          { required: true, message: "用户名不能为空", trigger: "blur" },
        ],
        password: [
          { required: true, message: "密码不能为空", trigger: "blur" },
        ],
        code: [{ required: true, message: "验证码不能为空", trigger: "blur" }],
      },
    };
  },
  methods: {
    async login() {
      this.loading = true;
      this.$refs.form.validate(async (valid) => {
        if (valid) {
          // await this.$store.dispatch("user/getLogin", this.formData);
          this.loading = false;
          Message.success("登录成功！");
          this.$router.push("/home");
        }
      });
    },
  },
};
</script>

<style lang="less" scoped>
/deep/.el-button--success {
  width: 100%;
  border-radius: 17px;
  padding: 11px 20px !important;
  margin-top: 10px;
  font-weight: 500;
  font-size: 12px;
  border: 0;
}
/deep/.el-input__inner {
  border: none;
  outline: none;
  border-radius: 0;
}
/deep/.el-input__inner {
  border-bottom: 1px solid #e9e9e8;
  outline: none;
}

.code {
  position: absolute;
  left: 130px;
  top: 9px;
  width: 85px;
  height: 32px;
  object-fit: cover;
}
.bg {
  background-color: #2b303b;
  height: 100vh;
  .box {
    display: flex;
    position: absolute;
    left: 0;
    bottom: 0;
    right: 0;
    top: 0;
    margin: auto;
    width: 957px;
    height: 483px;
    background-color: #fff;
    border-radius: 15px;
    .pic {
      width: 604px;
      img {
        height: 100%;
        width: 100%;
        object-fit: cover;
      }
    }
    .left {
      display: flex;
      flex-direction: column;
      // justify-content: start;
      align-items: center;
      flex: 1;
      padding: 62px 72px 0 66px;
      .left_pic {
        display: flex;
        align-items: center;
        margin-bottom: 20px;

        img {
          width: 33px;
          margin-right: 10px;
          height: 36px;
        }
      }
    }
  }
}
</style>